home *** CD-ROM | disk | FTP | other *** search
/ Just Call Me Internet / Just Call Me Internet.iso / patches / hsmoda07 / hsm_doku / prog_man.txt < prev    next >
Text File  |  1994-05-16  |  10KB  |  222 lines

  1. Programmers Manual for SERSOFST.TXT-compatible drivers
  2. ======================================================
  3.  
  4. Dies ist in Englisch geschrieben, weil anscheinend besonders die nicht 
  5. deutsch sprechenden Programmierer besondere Schwierigkeiten haben. Man mag 
  6. darber denken, wie man will.
  7.  
  8. Because the non-German developers seems to have more difficulties than the 
  9. Germans, this text is in English language.
  10.  
  11. It is a _quick_ collection of some hints. I repeat me: I'm not payed for 
  12. doing this and it would be very nice, if I would get some sample code or 
  13. so from other people.
  14.  
  15.  
  16. Literature
  17. ----------
  18. A real programmer should read the SERSOFST.TXT, the RSVF_COO.TXT and the 
  19. text files of drivers and DRVIN. The MiNT documentation is also a source.
  20.  
  21.  
  22. BIOS/XBIOS versus GEMDOS
  23. ------------------------
  24. At the moment you may mix GEMDOS-calls and BIOS/XBIOS-calls for one 
  25. port. But I recommend only to use the GEMDOS-calls, if you like to write a 
  26. "nice" program. I you maintain an old program (which uses only (X)BIOS 
  27. and direct hardware accesses), and you like to make it 
  28. "clean", then it should have a user-selectable possibility only to use 
  29. (X)BIOS and _not_ to access the hardware directly.
  30.  
  31.  
  32. GEMDOS and the AUX
  33. ------------------
  34. Atari recommends not to use the GEMDOS-AUX, especially the GEMDOS-calls 
  35. number 3, 4, 18, 19. I recommend too not to use this calls and even not to 
  36. use the "AUX:" or "U:\DEV\AUX", because this dirty things aren't 
  37. supported, that means, they remain very slow under TOS. GEMDOS number 3, 
  38. 4, 18, 19 is the slowest way, because your program does an trap#1 to the 
  39. gemdos and the gemdos does a trap#13 to the bios (for bios device number 
  40. 1). Additionally, that means that the GEMDOS could redirect this calls to 
  41. another thing and the BIOS could do it again. If you use these 
  42. gemdos-calls despite all warnings, you have to set the correct interface 
  43. configuration via XBIOS Rsconf, and the correct BIOS device via Bconmap 
  44. (if available).
  45.  
  46.  
  47. Opening a port
  48. --------------
  49. If there is a RSVF-cookie (see RSVF_COO.TXT) then you can find out which 
  50. ports are availabe and which GEMDOS-names and BIOS-numbers they have. 
  51. Mostly there will be a MODEM1.
  52.  
  53. You get a handle for this by using the GEMDOS-Fopen-function called with 
  54. the name "U:\DEV\MODEM1". (C-Programmers: double the backslashs). This 
  55. will work if DRVIN (and the driver) is installed, under MiNT, unter MagiC.
  56.  
  57. Handling the I/O-ports like files is the normal way under many modern 
  58. operating systems. And it is a fast way, because you can transfer many 
  59. characters at on call.
  60.  
  61.  
  62. Using the handle
  63. ----------------
  64. Please read the SERSOFST.TXT. It explains nearly everything.
  65.  
  66. Some remarks: Fread and Fwrite work normally in a non-blocking mode, that 
  67. means if you pass more bytes to Fwrite than actually can be transfered 
  68. into the transmitter buffer (from the buffer they are transmitted by an 
  69. interrupt routine or any other way not interesting for the application 
  70. programmer), then the first n bytes will be transfered (n = as much as fit 
  71. into the buffer) and Fwrite returns this n. This is the same behavior 
  72. which shows Fwrite if you try to write to a disk which becomes full. And 
  73. in a multitask system an other task could delete a file on the disk and a 
  74. subsequent Fwrite will write again some bytes, the same way it works on 
  75. this I/O-ports.
  76.  
  77. If you request more bytes than actually available via Fread, then Fread 
  78. will return as much bytes as available and the number of bytes. The same 
  79. way as trying to read more bytes from a file on disk then being in this 
  80. file.
  81.  
  82.  
  83. Why this SERSOFST.TXT-standard?
  84. -------------------------------
  85. I think it's explained in the SERSOFST.TXT. Again: It makes programs fast 
  86. (faster than using only BIOS at the clean way) and independend form the 
  87. underlaying hardware. All good Atari-emulators provide a 
  88. SERSOFST-compatible interface for the serial ports, that is my personal 
  89. opinion (yes, there are even bad emulators. That is my personal opinion. 
  90. Harun Scheutzow. Ask for SERSOFST.TXT/HSMODA-support :-) ). And if your 
  91. program is clean, using the SERSOFST-stuff, it will run on every port, no 
  92. matter whether this port is a MFP, a SCC, a 82550-FIFO-UART, an ACIA, some 
  93. mystic hardware of an Atari-emulator, or even an emulated modem via a 
  94. large network.
  95.  
  96. Using clean programs (as Connect, GSZRZ, a self written Midicom-driver and 
  97. so on) I had some successes even on unusual hardware: the programs runned 
  98. correctly without any change on the Macintosh with the MagiCMac. The only 
  99. precondition was the SERSOFST-conform driver for that hardware.
  100.  
  101.  
  102. Speed
  103. -----
  104. Some people believe that serial communications have to be slow all the 
  105. time. But even an old 8MHz-ST can transmit more than 15000cps 
  106. (15KByte/second) via a SERSOFST-compatible driver using a well implemented 
  107. Zmodem. This speeds become interesting for ISDN (or servicing more than 
  108. one modem per computer).
  109.  
  110.  
  111. Buffer sizes and XBIOS Iorec
  112. ----------------------------
  113. As long as (or if) the Fcntl TIOCBUFFER isn't implemented (that means it 
  114. returns an error if requesting the actual buffer sizes), it is legal to 
  115. change the size and address and water marks of buffers directly in the 
  116. IOREC. The clean way for this direct access: Switch to "no handshake", 
  117. disable the interrupts, change the buffers, re-enable the interrupts, 
  118. switch to the old handshake mode.
  119.  
  120.  
  121. DTR on MODEM2/SERIAL2 via direct access, The SCC
  122. ------------------------------------------------
  123. (ugly things not directly associated with SERSOFST)
  124. The Atari developer documentation is _very_ _wrong_. If you use the 
  125. drivers you aren't in need of accessing DTR directly in the hardware. But 
  126. if you do it, do it in the _only_ _one_ correct way:
  127.  
  128. disable interrupts
  129. get the WR5-shadow-register from IOREC(of this port)+$1D (it is a byte)
  130. modify this shadow and write it back into the IOREC
  131. select WR5 in the SCC
  132. write the shadow into the SCC (WR5)
  133. re-enable interrupts (restore old state)
  134.  
  135. This shadow exists because it's impossible on normal SCCs to read WR5 (and 
  136. even on enhanced SCCs it is difficult and slow). This shadow exist for 
  137. MODEM2 and SERIAL2 (the SCC ports) in all TOS-versions and MagiC and even 
  138. the SERSOFST-drivers (for compatibility).
  139.  
  140. HINT! Disable the interrupts every time you like to access a SCC-register 
  141. other than RR0, WR0 and the data-register (directly, not via WR8/RR8). If 
  142. you forget it, and your program wrote the register number into WR0, there 
  143. may come an interrupt and access the SCC too, producing trouble, because 
  144. the SCC thinks the value the interrupt routine writes to WR0 is some data 
  145. and not a new register number, returning to your program the trouble 
  146. continues. (The only way to end it: read from RR0, and forgetting the read 
  147. data. You can read/write from/to RR0/WR0 without first writing a 0 to WR0, 
  148. if you look into the TOS, you see that it writes 0es, this is nonsens, 
  149. forget this senceless behavior!)
  150.  
  151.  
  152. The Function Fcntl
  153. ------------------
  154. In a C-language environment this function ist normally declared in a 
  155. header file either
  156. LONG Fcntl(WORD handle, LONG special, WORD command);
  157. or
  158. LONG Fcntl(WORD handle, void * special, WORD command);
  159.  
  160. Sometimes LONG is replaced by long and WORD by int.
  161.  
  162. The function itself is defined (implemented) either in an other header 
  163. file by using more or less compiler dependent methods (inline or a 
  164. gemdos()-function) or in a library. As long as your compiler passes the 
  165. parameters on the stack, the both declarations are identical on Ataris, 
  166. because LONG and void * use the same amount of storage (4 bytes) on the 
  167. stack.
  168.  
  169. But if your compiler passes the parameters in registers to a library 
  170. function and it distinguishes between "normal data" and pointers, like the 
  171. PureC, you must use the correct declaration as supplied with your 
  172. compiler package.
  173.  
  174. Like nearly all GEMDOS functions, Fcntl returns 32 Bit, a LONG, as the 
  175. function result. You should correct it in the headers of of your compiler, 
  176. if it is wrong there.
  177.  
  178. In most cases "special" is the placeholder for a pointer to something. I 
  179. will give an example of use for both declaration variants. I like to call 
  180. the Fcntl TIOCIBAUD to set the input baud rate.
  181.  
  182. LONG my_err;
  183. LONG baudrate;
  184. WORD my_handle;
  185.  
  186. /* Open a device and assign a useable value to "my_handle" */
  187.  
  188. baudrate = 9600L;
  189.  
  190. /* if declared "LONG special" then use */
  191. my_err = Fcntl(my_handle, (LONG)(&baudrate), TIOCIBAUD);
  192.  
  193. /* if declared "void * special" then use */
  194. my_err = Fcntl(my_handle, &baudrate, TIOCIBAUD);
  195.  
  196.  
  197. The Subfunction Fcntl TIOCFLUSH
  198. -------------------------------
  199. There is an _incompatibility_ between all drivers from HSMODA* and MACM1* 
  200. packages and MiNT. MiNT assumes that the "special" parameter of this 
  201. TIOCFLUSH Fcntl is a pointer to a long which contains the information 
  202. about the desired flush, but the HSMODA* and MACM1* assume "special" 
  203. itself contains this information, that means it is not a pointer.
  204.  
  205. I try to fix this in a compatible way in the next HSMODA-package, 
  206. HSMODA08. The compatible fix-way I will use if I do it: If special is 0, 
  207. 1, 2 or 3, then it is the desired flush itself. If special is larger, and 
  208. any valid pointer is larger with nearly 100% probability, then it is a 
  209. pointer to the desired flush type. But at the moment I'm not shure how to 
  210. handle negative special values. So my question: Does anybody use negative 
  211. special values? (I could assume that any valid pointer is signed-positive, 
  212. or that signed-negative values are only near by 0 are invalid pointers 
  213. ...)
  214.  
  215. Dear Developer, if you currently use TIOCFLUSH, please give a short 
  216. response via email to Harun_Scheutzow@h.maus.de or 
  217. harun@village.village.de.
  218.  
  219.  
  220.  
  221. Harun Scheutzow, 1994-11-25 and later
  222.